home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Graphics / include / matrix_3d.h < prev    next >
Encoding:
Text File  |  1995-03-25  |  3.5 KB  |  63 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    matrix_3d.h
  3. //    Date:                    8/29/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains class declaration for a matrix_3d
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include "tuple_3d.h"
  11.  
  12. #ifndef    MATRIX_3D
  13. #define    MATRIX_3D
  14.  
  15. //------------------------------------------------------------------------------
  16. //    classes
  17. //------------------------------------------------------------------------------
  18. class    matrix_3d                                                                                                                                    //    matrix_3d class
  19. {                                                                                                                                                                //    begin matrix_3d class definition
  20.     private:                                                                                                                                            //    private interface
  21.     protected:                                                                                                                                        //    protected interface
  22.         real            mat[4][4];                                                                                                                //    array representing the matrix_3d
  23.     public:                                                                                                                                                //    public interface
  24. static    real    identity[4][4];                                                                                                        //    array used for constructing identity matrices
  25.         matrix_3d (void) {}                                                                                                                    //    default constructor
  26.         matrix_3d (matrix_3d &m);                                                                                                        //    copy constructor
  27.         matrix_3d (real f[4][4]);                                                                                                        //    direct assignment constructor
  28.         void            operator = (const matrix_3d &m);                                                                    //    assignment operator
  29.         real            &operator () (int r, int c);                                                                            //    function call operator
  30. const    real        &operator () (int r, int c) const;                                                                //    function call operator
  31.         matrix_3d    operator * (const matrix_3d &m) const;                                                        //    multiplication operator
  32.         real            Cofactor (int r, int c) const;                                                                        //    compute the cofactor for the given entry
  33.         real            Determinant (void) const;                                                                                    //    compute the matrix_3d determinant
  34.         matrix_3d    Inverse (void) const;                                                                                            //    compute the matrix_3d inverse
  35. };                                                                                                                                                            //    end matrix_3d class definition
  36.  
  37. //------------------------------------------------------------------------------
  38. //    inlines
  39. //------------------------------------------------------------------------------
  40. inline    real    &matrix_3d::operator () (int r, int c)                                                        //    function call operator
  41. {                                                                                                                                                                //    begin
  42.     return (mat[r][c]);                                                                                                                        //    return the appropriate indexed real
  43. }                                                                                                                                                                //    end
  44.  
  45. inline    const    real    &matrix_3d::operator () (int r, int c) const                                //    function call operator
  46. {                                                                                                                                                                //    begin
  47.     return (mat[r][c]);                                                                                                                        //    return the appropriate indexed real
  48. }                                                                                                                                                                //    end
  49.  
  50. //------------------------------------------------------------------------------
  51. //    operator functions
  52. //------------------------------------------------------------------------------
  53. tuple_3d    operator * (const tuple_3d &t, const matrix_3d &m);                                        //    pre-multiplication operator with a row vector_3d
  54. tuple_3d    operator * (const matrix_3d &m, const tuple_3d &t);                                        //    post-multiplication operator with a column vector_3d
  55.  
  56. //------------------------------------------------------------------------------
  57. //    global variables
  58. //------------------------------------------------------------------------------
  59. extern    matrix_3d    IDENTITY_MATRIX;                                                                                            //    an identity matrix_3d
  60.  
  61. //------------------------------------------------------------------------------
  62.  
  63. #endif    //MATRIX_3D